{extend name="public/base" /}
{block name="body"}
<div class="ibox float-e-margins">
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li><strong>七日内产品销量统计</strong></li>
	</ol>
</div>
{include file="pro_enter/top"}
	<div class="ibox-content">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="JavaScript:ysum();" class="btn btn-primary btn-outline">优惠购</a>
<a href="JavaScript:fsum();" class="btn btn-primary btn-outline">疯狂抢</a>
<a href="JavaScript:zsum();" class="btn btn-primary btn-outline">赚积分</a>
<a href="JavaScript:psum();" class="btn btn-primary btn-outline">云拼团</a>
		<h1 id="dh">优惠购</h1>
		<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('index')}">
			<!--统计图-->
			<div id="main" style="width: 98%;height:500px;"></div>
       </form>    
	</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__JS__/echarts.common.min.js"></script>
<style>
	.order-info .info-group{width:25%; text-align:center; float:left;}
	.order-info .info-group+.info-group{border-left:1px dotted #ccc; }
	.h4{font-size:22px; display:block;}
	
	
</style>
<script>
//导航
$("#li-bar-index").addClass("active");
var myChart = echarts.init(document.getElementById('main'));
var dh=document.getElementById('dh');
var data1=[];
var data2=[];
	var arr = <?php echo json_encode($ysum);?>;
	var aarr = eval(arr);
for(var i=0 ;i<aarr.length;i++){
	data1[i]=aarr[i].goods_name;
	data2[i]=aarr[i].p;
}
updata(data1,data2);
function fsum(){
	var fsum1=[];
	var fsum2=[];
	var arr = <?php echo json_encode($fsum);?>;
	var aarr = eval(arr);
for(var i=0 ;i<aarr.length;i++){
	fsum1[i]=aarr[i].goods_name;
	fsum2[i]=aarr[i].p;
}
dh.innerHTML='疯狂抢';
updata(fsum1,fsum2);
}
function psum(){
	var psum1=[];
	var psum2=[];
	var arr = <?php echo json_encode($psum);?>;
	var aarr = eval(arr);
for(var i=0 ;i<aarr.length;i++){
	psum1[i]=aarr[i].goods_name;
	psum2[i]=aarr[i].p;
}
dh.innerHTML='云拼团';
updata(psum1,psum2);
}
function ysum(){
	var ysum1=[];
	var ysum2=[];
	var arr = <?php echo json_encode($ysum);?>;
	var aarr = eval(arr);
for(var i=0 ;i<aarr.length;i++){
	ysum1[i]=aarr[i].goods_name;
	ysum2[i]=aarr[i].p;
}
dh.innerHTML='优惠购';
updata(ysum1,ysum2);
}
function zsum(){
	var zsum1=[];
	var zsum2=[];
	var arr = <?php echo json_encode($zsum);?>;
	var aarr = eval(arr);
for(var i=0 ;i<aarr.length;i++){
	zsum1[i]=aarr[i].goods_name;
	zsum2[i]=aarr[i].p;
}
dh.innerHTML='赚积分';
updata(zsum1,zsum2);
}
function updata(p1,p2){
option = {
    color: ['#3398DB'],
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
		feature: {
		    saveAsImage: {}
		}
    },
    xAxis : [
        {
            type : 'category',
            data : p1,
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'产品销量',
            type:'bar',
            barWidth: '60%',
            data:p2
        }
    ]
	};
 myChart.setOption(option);
}
	   
</script>
{/block}